<template>
  <div class="app-container">
    <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="90px">
      <el-form-item label="客户姓名：" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="客户姓名"
          clearable
          style="width: 300px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号码：" prop="clientPhone">
        <el-input
          v-model="queryParams.phone"
          placeholder="客户手机号码"
          clearable
          style="width: 300px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号：" prop="clientID">
        <el-input
          v-model="queryParams.citizenIdentity"
          placeholder="客户身份证号"
          clearable
          style="width: 300px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="渠道名称：" prop="channel">
        <el-input
          v-model="queryParams.channelName"
          placeholder="渠道名称"
          clearable
          style="width: 300px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提交时间：">
        <el-date-picker
          v-model="dateRange"
          style="width: 300px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        />
      </el-form-item>
      <el-form-item label="申请状态：" prop="appliedStatus">
        <el-select v-model="queryParams.appliedStatus" placeholder="全部" clearable style="width: 300px">
          <!-- 字典状态，dict.type.你添加进字典的类型 -->
          <el-option
            v-for="dict in dict.type.loan_info_applicant_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <div style="margin-right: 50px;">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <!-- <el-button icon="el-icon-refresh" size="mini" @click="handleExport">导出</el-button> -->
        </div>
      </el-form-item>
    </el-form>
    <!-- data=你后台查出的数据 -->
    <el-table v-loading="loading" :data="trialList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="40" align="center" />
      <el-table-column label="产品名称" align="center" prop="productionName" />
      <el-table-column label="客户姓名" align="center" prop="clientName" />
      <el-table-column label="申请金额" align="center" prop="loanAmount" />
      <el-table-column label="期数" align="center" prop="periods" />
      <el-table-column label="累计放款" align="center" prop="loansTotal" />
      <el-table-column label="申请状态" align="center" prop="applicantStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.loan_info_applicant_status" :value="scope.row.applicantStatus" />
        </template>
      </el-table-column>
      <el-table-column label="渠道" align="center" prop="channelName" />
      <el-table-column label="提交时间" align="center" prop="applicantTime" widtn="180px">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applicantTime)}}</span>
        </template>
      </el-table-column>
      <el-table-column label="申请次数" align="center" prop="applicantNum" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <router-link :to="'/order/firstTrial-detail/index/' + scope.row.id" class="link-type">
            <el-button
              v-hasPermi="['system:user']"
              size="mini"
              type="text"
            >初审</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
// 导入api
import { LlistFirstTrial } from '@/api/firstTrial'
export default {
  name: 'FirstTrial',
  // 字典导入
  dicts: ['loan_info_applicant_status', 'loan_info_audit_result'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      trialList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        clientName: undefined,
        phone: undefined,
        citizenIdentity: undefined,
        channelName: undefined
      },
      // 表单参数
      form: {}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      LlistFirstTrial(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.trialList = response.rows
        this.total = response.total
        this.loading = false
      })
      this.loading = false
    },
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    cancel() {
      this.open = false
      this.reset()
    },
    reset() {
      this.form = {
        status: '0'
      }
      this.resetForm('form')
    },
    handleExport() {
      this.download('导出文件存放路径', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.postId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    }
  }

}

</script>

